package com.zhouchao.demo.controller;

import com.zhouchao.demo.service.IDemoService;
import com.zhouchao.mvcframework.annotations.Autowired;
import com.zhouchao.mvcframework.annotations.Controller;
import com.zhouchao.mvcframework.annotations.RequestMapping;
import com.zhouchao.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/demo")
@Security({"1"})
public class DemoController {

    @Autowired
    private IDemoService demoService;

    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @RequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }

    /**
     * URL: /demo/query/01?name=lisi&username=1
     * @param request
     * @param response
     * @param name
     * @return
     */
    @Security({"1","2","3"})
    @RequestMapping("/query/01")
    public String query01(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }

    /**
     * URL: /demo/query/02?name=lisi&username=1
     * @param request
     * @param response
     * @param name
     * @return
     */
    @Security({"2"})
    @RequestMapping("/query/02")
    public String query02(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }

    /**
     * URL: /demo/query/03?name=lisi&username=1
     * @param request
     * @param response
     * @param name
     * @return
     */
    @RequestMapping("/query/03")
    public String query03(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }
}
